<template>
  <div >
    <el-breadcrumb>
      <el-breadcrumb-item>港口管理</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="PortFormBox">
      <el-form ref="PortFormRef" :model="PortForm" :rules="PortFormRules" class="PortForm_sty">
        <el-form-item prop="port_id">
          <el-input v-model="PortForm.number">
            <template slot="prepend">仓库编号</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="port_specified">
          <el-input v-model="PortForm.specified">
            <template slot="prepend">核定容量</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="port_used">
          <el-input v-model="PortForm.used">
            <template slot="prepend">仓库已用容量</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="port_surplus">
          <el-input v-model="PortForm.surplus">
            <template slot="prepend">仓库剩余容量</template>
          </el-input>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" @click="inserPort" round>提交</el-button>
          <el-button type="info" @click="resetuserForm" round>重置</el-button>
        </el-form-item>
      </el-form>
      <el-dialog
        title="提示"
        :visible.sync="sucessVisible"
        width="30%">
        <span>提交成功</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="sucessVisible = false">取 消</el-button>
          <el-button type="primary" @click="sucessVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      PortForm: {
        port_id: '',
        port_specified: '',
        port_used: '',
        port_surplus: ''
      },
      PortFormRules: {
        port_id: [
          { required: true, message: '请输入仓库编号', trigger: 'blur' }
        ],
        port_specified: [
          { required: true, message: '请输入核定容量', trigger: 'blur' }
        ],
        port_used: [
          { required: true, message: '请输入仓库已用容量', trigger: 'blur' }
        ],
        port_surplus: [
          { required: true, message: '请输入仓库剩余容量', trigger: 'blur' }
        ]
      },
      sucessVisible: false
    }
  },
  methods: {
    resetPortForm() {
      this.$refs.PortFormRef.resetFields()
    },
    inserPort() {
      const { data: res } = this.$http.post('customer', {
        port_id: this.PortForm.number,
        port_specified: this.PortForm.specified,
        port_used: this.PortForm.used,
        port_surplus: this.PortForm.surplus
      })
      this.emidtsucess()
      console.log(res)
    },

    emidtsucess() {
      this.sucessVisible = true
    }
  }
}
</script>

<style lang="less" scoped>
  .el-form-item{
    width: 500px;
  }
  .PortFormBox{
    background-color: #fffffb;
    height: 400px;
    width: 1210px;
    border-radius: 5px;
    margin-left: 10px;
  }
  .PortForm_sty{
    position: absolute;
    padding: 30px 60px 30px;
    box-sizing: border-box;
  }
  .btns{
    display: flex;
    justify-content: flex-start;
    margin-top: 60px;
  }
</style>
